"""
练习2：定义函数,在列表中找出所有数字
 [43,"悟空",True,56,"八戒",87.5,98]

"""

list1 = [43,"悟空",True,56,"八戒",87.5,98]

# def get_num(list1):
#     for item in list1:
#         if type(item) in (int,float):
#             yield item
#
# for num in get_num(list1):
#     print(num)

# def get_num(list1):
#     for item in list1:
#         if type(item) == int or type(item) == float:
#             yield item
#
# for num in get_num(list1):
#     print(num)

def get_num(list1):
    for item in list1:
        if isinstance(item, (int,float)) and not isinstance(item, bool):
            yield item

for num in get_num(list1):
    print(num)